<?php if(isset($rows)) :?>

	<ul data-role="listview">
	<li data-role="list-divider" data-theme="b"> Sat, Mar 9, 2012</li>
	
	<?php $stack = array(); ?>
	
	<?php for ($i = 0; $i<sizeof($rows) ; $i++) :?>
	
	<?php if ( !in_array($rows[$i]->senderid, $stack) && !in_array($rows[$i]->receiverid, $stack)) :?>
	
				
	
		

	<li data-icon="false">
		<?php if($rows[$i]->senderid == $this->session->userdata('userid')) : ?>
		<a href="<?=site_url('messege_controller/to_send_messege?receiverid='.$rows[$i]->receiverid);?>" >
		
		<?php else: ?>
		
		<a href="<?=site_url('messege_controller/to_send_messege?receiverid='.$rows[$i]->senderid);?>" >
		
		<?php endif; ?>
		 
		


		<?php
		$filename=$rows[$i]->avatar_name;
		$gallery_path_url=base_url().'images/thumbs/'.$filename;
		$gallery_path = realpath(APPPATH . '../images/thumbs/');
		$avatar_path=$gallery_path.$filename;
		if(!file_exists($avatar_path)):
		?>
		<p>
		<?php endif; ?>
		<p><b><?=$rows[$i]->sender_name?>
		 to <?=$rows[$i]->receiver_name?></b></p>
		<p><?=$rows[$i]->content;?></p>
		<p class="ui-li-aside"> 8:00pm </p>
		
		</a>	
		
		</li>
		
		<?php endif; ?>
		
	<?php if(($rows[$i]->senderid == $this->session->userdata('userid') )&& (!in_array($rows[$i]->receiverid,$stack)) )
			array_push($stack,$rows[$i]->receiverid); ?>
	<?php if(($rows[$i]->senderid != $this->session->userdata('userid') )&& (!in_array($rows[$i]->receiverid,$stack)) )
			array_push($stack,$rows[$i]->senderid); ?>

<?php endfor; ?>

</ul>






<?php else :?>
<!--<?php echo 'There is no Message!';?>-->
<h4>You don't have any messages!</h4>
<?php endif; ?>


</div>
</body>
</html>